<?php
if (!defined('IN_CONTEXT')) die('access violation error!');
?>
<link rel="stylesheet" type="text/css" href="./script/js/autocomplete/jquery.autocomplete.css" />
<script type="text/javascript" src="./script/js/autocomplete/jquery.autocomplete.js"></script>
<script type="text/javascript" language="javascript">
<!--
<?php
if($templates['tpl_status'] == 1 || $templates['tpl_status'] == 6)
{
?>
$(document).ready(function(){
	var tpl_domain = [
		<?php echo '"'.$templates['tpl_name'].'.site0.sitestar.cn'.'"';?>
	];
	$("#tpl_domain").focus().autocomplete(tpl_domain);
});
<?php 
}
?>

function masterPass()
{
	$("#tpl_info").append("<input type='hidden' name='_info' value='masterPass'/>");
}

function masterUnpass()
{
	$("#tpl_info").append("<input type='hidden' name='_info' value='masterUnpass'/>");
}

function testerUnpass()
{
	$("#tpl_info").append("<input type='hidden' name='_info' value='testerUnpass'/>");
}

function testerPass()
{
	$("#tpl_info").append("<input type='hidden' name='_info' value='testerPass'/>");
}

function publisher_update()
{
	$("#tpl_info").append("<input type='hidden' name='_info' value='publisherUpdate'/>");
}

function check_editTemplate_info(thisForm)
{
	$("#stat").css({"display":"block"});
	$("#stat").html("正在保存内容......");
	_ajax_submit(thisForm, on_success, on_failure);
	return false;
}

function on_success(response)
{
	response1 = eval("("+response+")");
	var stat = document.getElementById("stat");
	if(response1.result == 'ok')
	{
		alert(response1.sucmsg);
		stat.innerHTML = "OK，正在重定向......";
		if(response1.status == '6')
		{
			window.location.href = response1.forward;
		}
		else if(response1.status == '8')
		{
			window.location.href = response1.forward;
		}
		else
		{
			window.location.href = 'index.php?_m=job&_a=myJobPage';
		}
	}
	else if(response1.result == 'error')
	{
		stat.innerHTML = response1.errmsg;
	}
}

function on_failure(response)
{
	var stat = document.getElementById("stat");
	stat.innerHTML = response;
}
-->
</script>
<style type="text/css">
table {
	<?php 
	if(!empty($item_link))
	{
		echo "margin-top:2px;";	
	}
	else
	{
	?>
	margin-top:20px;
	<?php }?>
	position:relative;
	right:7px;
}
table td {
	text-align:left;
}
.table_title {
	text-align:center;
}
</style>
<div id="stat" style="margin-top:20px;font-size:12px;display:none;"></div>
<?php 
if(!empty($item_link))
{
	echo "<p style='font-size:12px;margin-bottom:2px;margin-top:20px;'>测试页面|<a href='$item_link'>检测项页面</a></p>";
}
?>
<form id="tpl_info" method="post" action="index.php" onsubmit="javascript:return check_editTemplate_info(this);">
<input type="hidden" name="_m" value="<?php echo $next_controller;?>"/>
<input type="hidden" name="_a" value="<?php echo $next_action;?>"/>
<input type="hidden" name="tpl_id" value="<?php echo $templates['tpl_id'];?>"/>
<table width="100%" border="0" cellpadding="2" cellspacing="0" bordercolor="#4c4c4c">
<!-- 按钮信息 -->
<tr>
<?php if(!empty($submit_button_name)) {
	if($templates['tpl_status'] == 2) $onclick = "onclick='masterPass();'";
	if($templates['tpl_status'] == 5)
	{
		$onclick = ($allow_submit_pass) ? "onclick='testerPass();'" : "disabled='disabled' title='测试项没有完全通过'";
	}
?>
<td colspan="6"><input type="submit" <?php echo $onclick;?> value="<?php echo $submit_button_name;?>"/><?php echo $button_nopass;?><?php echo $update_button;?><input type="reset" value="重置"/>
<?php if($templates['tpl_status'] == 5){?>
&nbsp;&nbsp;&nbsp;<span style='font-size:12px;'>提示:检测项必须全部通过才能通过测试&nbsp;&nbsp;<a href='index.php?_m=job&_a=checkItemPage&tpl_id=<?php echo $templates['tpl_id'];?>'>检测项页面</a></span>
<?php } elseif($templates['tpl_status'] == 1) {?>
&nbsp;&nbsp;&nbsp;<span style='font-size:12px;'>提示:一般由设计人员操作</span>
<?php }?>
</td>
<?php }?>
</tr>
<!-- 按钮信息 -->

<!-- 模板信息 -->
<tr><td colspan="6" class="table_title">模板信息</td></tr>
<tr>
	<td width="16%">模板编号</td>
	<?php if($templates['tpl_status'] != 6) {?>
	<td width="16%"><label><?php echo $templates['tpl_name'];?></label></td>
	<?php } else {?>
	<td width="16%"><input type="text" name="tpl_name" value="<?php echo $templates['tpl_name'];?>"/></td>
	<?php }?>
	<td width="18%">模板行业</td>
	<td width="16%"><label><?php echo $template_categories['tpl_category_name'];?></label></td>
	<td width="18%">模板状态</td>
	<td width="16%"><label><?php echo $status_alias;?></label></td>
</tr>
<tr>
	<td>软件版本</td>
	<td><label><?php echo $templates['tpl_software_version'];?></label></td>
	<td>制作类型</td>
	<td><label><?php echo $tpl_type;?></label></td>
	<td>*三级域名</td>
	<?php 
	if($templates['tpl_status'] > 1 && $templates['tpl_status'] != 6) {
		$tpl_domain = empty($templates['tpl_domain']) ? '-' : $templates['tpl_domain'];
		if(!(strpos($tpl_domain, 'http') === false))
		{
			$length = strlen($tpl_domain) - 7;
			$tpl_domain = substr($tpl_domain,-1 * $length,$length); 
		}
	?>
	<td><label><a target= "_blank" href="http://<?php echo $tpl_domain;?>"><?php echo $tpl_domain;?></a></label></td>
	<?php } else {?>
	<td><input type="text" id="tpl_domain" name="tpl_domain" value="<?php echo $templates['tpl_domain'];?>"/></td>
	<?php }?>
</tr>
<tr>
	<td>模板名称</td>
	<?php if($templates['tpl_status'] != 6) {?>
	<td colspan="5"><label><?php echo $templates['tpl_chinese_name'];?></label></td>
	<?php } else {?>
	<td colspan="5"><input type="text" name="tpl_chinese_name" value="<?php echo $templates['tpl_chinese_name'];?>"/></td>
	<?php }?>
</tr>
<!-- 模板信息 -->

<!-- 人员信息 -->
<tr><td class="table_title" colspan="6">人员信息</td></tr>
<tr>
<td>派发人员</td>
<td><label><?php echo $users[$templates['tpl_master_id']];?></label></td>
<td>设计人员</td>
<td><label><?php echo $users[$templates['tpl_designer_id']];?></label></td>
<td>测试人员</td>
<td>
<?php 
if($templates['tpl_status'] == 3)
{
	echo '<select name="tpl_tester_id">';
	foreach($testers as $v)
	{
		if($v['u_id'] == $templates['tpl_tester_id'])
		{
			echo "<option selected='selected' value='{$v['u_id']}'>{$v['u_name']}</option>";
		}
		else
		{
			echo "<option value='{$v['u_id']}'>{$v['u_name']}</option>";
		}
	}
	echo '</select>';
}
else
{
?>
	<input readonly="readonly" type="text" name="tpl_tester_leader_id" value="<?php echo $users[$templates['tpl_tester_id']];?>"/>
<?php
}
?>

</td>
</tr>
<tr>
<td>测试组长</td>
<td><input readonly="readonly" type="text" name="tpl_tester_leader_id" value="<?php echo $users[$templates['tpl_tester_leader_id']];?>"/></td>
<td>发布人员</td>
<td colspan="3"><input readonly="readonly" type="text" name="tpl_publisher_id" value="<?php echo $users[$templates['tpl_publisher_id']];?>"/></td>
</tr>
<!-- 人员信息 -->

<!-- 时间信息 -->
<tr><td class="table_title" colspan="6">时间信息</td></tr>
<tr>
<td>派发时间</td>
<?php 
if(!empty($templates['tpl_assign_time'])) 
{
	$assign_time = date('Y-m-d H:i:s',$templates['tpl_assign_time']); 
}
else
{
	$assign_time = '-';
}

if(!empty($templates['tpl_master_allow_time']))
{
	$tpl_master_allow_time = date('Y-m-d H:i:s',$templates['tpl_master_allow_time']); 
}
else
{
	$tpl_master_allow_time = '-';
}
?>
<td><label><?php echo $assign_time;?></label></td>
<td>总监审核通过时间</td>
<td><input readonly="readonly" type="text" name="tpl_master_allow_time" value="<?php echo $tpl_master_allow_time;?>"></td>
<td>测试人员测试通过时间</td>
<?php 
if(!empty($templates['tpl_allow_time']))
{
	$tpl_allow_time = date('Y-m-d H:i:s',$templates['tpl_allow_time']);
} 
else
{
	$tpl_allow_time = '-';
}
?>
<td><input readonly="readonly" type="text" name="tpl_allow_time" value="<?php echo $tpl_allow_time;?>"></td>
</tr>
<tr>
<td>发布时间</td>
<?php 
if(!empty($templates['tpl_finish_time']))
{
	$tpl_finish_time = date('Y-m-d H:i:s',$templates['tpl_finish_time']); 
}
else 
{
	$tpl_finish_time = '-';
}
?>
<td colspan="5"><input readonly="readonly" type="text" name="tpl_finish_time" value="<?php echo $tpl_finish_time;?>"></td>
</tr>
<!-- 时间信息 -->

<!-- 备注信息 -->
<tr><td class="table_title" colspan="6">备注信息</td></tr>
<tr>
<td>总监设计要求</td>
<td colspan="5"><textarea cols="45" rows="10" readonly="readonly" name="tpl_master_assign_comment"><?php echo $templates['tpl_master_assign_comment'];?></textarea></td>
</tr>
<tr>
<td>设计人员意见</td>
<?php 
if(!($templates['tpl_status'] == 1 || $templates['tpl_status'] == 4 || $templates['tpl_status'] == 7))
{
	$readonly1 = "readonly='readonly'";
}
?>
<td colspan="5"><textarea cols="45" rows="10" <?php echo $readonly1;?> name="tpl_designer_comment"><?php echo $templates['tpl_designer_comment'];?></textarea></td>
</tr>
<tr>
<td>总监审核意见</td>
<?php 
if($templates['tpl_status'] != 2) $readonly2 = "readonly='readonly'";
?>
<td colspan="5"><textarea cols="45" rows="10" <?php echo $readonly2;?> name="tpl_master_comment"><?php echo $templates['tpl_master_comment'];?></textarea></td>
</tr>
<tr>
<td>测试人员意见</td>
<?php if($templates['tpl_status'] != 5) $readonly3 = "readonly='readonly'";?>
<td colspan="5"><textarea cols="45" rows="10" <?php echo $readonly3;?> name="tpl_tester_comment"><?php echo $templates['tpl_tester_comment'];?></textarea></td>
</tr>
<tr>
<td>发布人员意见</td>
<?php if($templates['tpl_status'] != 6) $readonly4 = "readonly='readonly'";?>
<td colspan="5"><textarea cols="45" rows="10" <?php echo $readonly4;?> name="tpl_publisher_comment"><?php echo $templates['tpl_publisher_comment'];?></textarea></td>
</tr>
<!-- 备注信息 -->
<tr>
<?php if(!empty($submit_button_name)) {
	if($templates['tpl_status'] == 2) $onclick = "onclick='masterPass();'";
	if($templates['tpl_status'] == 5)
	{
		$onclick = ($allow_submit_pass) ? "onclick='testerPass();'" : "disabled='disabled' title='测试项没有完全通过'";
	}
?>
<td colspan="6"><input type="submit" <?php echo $onclick;?> value="<?php echo $submit_button_name;?>"/><?php echo $button_nopass;?><?php echo $update_button;?><input type="reset" value="重置"/>
<?php if($templates['tpl_status'] == 5){?>
&nbsp;&nbsp;&nbsp;<span style='font-size:12px;'>提示:检测项必须全部通过才能通过测试&nbsp;&nbsp;<a href='index.php?_m=job&_a=checkItemPage&tpl_id=<?php echo $templates['tpl_id'];?>'>检测项页面</a></span>
<?php } elseif($templates['tpl_status'] == 1) {?>
&nbsp;&nbsp;&nbsp;<span style='font-size:12px;'>提示:一般由设计人员操作</span>
<?php }?>
</td>
<?php }?>
</tr>
</table>
</form>